﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;

// 定义类模板 
template <class NameType, class AgeType>
class Maker {
public:
	Maker(NameType name, AgeType age) {
		this->name = name;
		this->age = age; 
	}
	void printMaker() {
		cout << "{name=" << this->name << ", age=" << this->age << "}" << endl; 
	}
public:
	NameType name;
	AgeType age; 
};

// 使用类模板 
void test01() {
	// 类模板不会自动推导类型，要显式告诉编译器类型 
	Maker<string, int> m("悟空", 18);
	m.printMaker(); 
}

// 参数模板化  
template <class T1, class T2>
void func2(Maker<T1,T2> &m) {
	m.printMaker(); 
}
void test02() {
	Maker<double, int> m(10.1, 20);
	func2(m);
	
}

int main()
{

	test01(); 
	test02(); 

	system("pause");
	return EXIT_SUCCESS;
}